Class Communities

java.lang.Object
edu.claflin.finder.algo.clustering.Communities

public class Communities extends Object
Author:
Cesar Martin
  • Field Details

    • list

      private Map<Integer,List<Node>> list
      Map of Community Number to Nodes of the Community. Some algorithms may rely on these numbers staying in the same order.
    • g

      private Graph g
    • weighted

      private boolean weighted
    • m2

      private double m2
  • Constructor Details

    • Communities

      public Communities(Graph g, boolean weighted)
      Constructor to initialize 1-Node Communities from a Graph.
      Parameters:
      g - the graph
      weighted - finding weighted communities?
    • Communities

      public Communities(Map<Integer,List<Node>> list, Graph g, boolean weighted)
      Constructor to create Communities from existing Community group.
      Parameters:
      list - the existing Communities
      g - the graph
      weighted - finding weighted communities?
    • Communities

      private Communities(Map<Integer,List<Node>> list, Graph g, boolean weighted, double m2)
      Constructor called by copy(). Copies values without looping because the looping was done in copy().
      Parameters:
      list - the Communities
      g - the Graph
      weighted - finding weighted Communities?
      m2 - the m2
  • Method Details

    • copy

      public Communities copy()
    • size

      public int size()
    • isWeighted

      public boolean isWeighted()
    • getM2

      public double getM2()
    • get

      public List<Node> get(Integer key)
      Get Community.
      Parameters:
      key - the index of the Community
      Returns:
      the Community
    • keys

      public List<Integer> keys()
      Get Community indices.
      Returns:
      the Community indices
    • containsKey

      public boolean containsKey(Integer key)
      Whether the Community structure contains the given community index.
      Parameters:
      key - the community index
      Returns:
      true if the Community structure contains the index, false otherwise
    • getList

      public List<List<Node>> getList()
      Get Community structure as a List of Node Lists.
      Returns:
      the Communities as lists.
    • indexOfNode

      public int indexOfNode(Node n)
      Get the index of the Community the given Node is in.
      Parameters:
      n - the node
      Returns:
      the index of the Community the given Node is in.
    • NodesInSameCommunity

      public int NodesInSameCommunity(Node n1, Node n2)
      Determine if 2 Nodes are in the same Community.
      Parameters:
      n1 - NodeStats 1
      n2 - NodeStats 2
      Returns:
      1 if Nodes in same Community, 0 otherwise
    • connectedCommunities

      public boolean connectedCommunities(List<Node> c1, List<Node> c2)
      Determine whether 2 Communities are connected.
      Parameters:
      c1 - Community 1
      c2 - Community 2
      Returns:
      true if Communities are connected, false otherwise
    • a

      public double a(List<Node> c)
      Fraction of edges incident to Nodes in the given Community.
      Parameters:
      c - the Community
      Returns:
      the fraction of edges incident to Nodes in the Community
    • e

      public double e(List<Node> c1, List<Node> c2)
      Fraction of edges that join vertices in 2 given Communities.
      Parameters:
      c1 - Community 1
      c2 - Community 2
      Returns:
      the fraction of edges that join vertices in the 2 Communities
    • modularity

      public double modularity()
      The Community Structure Quality Measure used by the algorithms. It is the sum of the fractions of the deviation edges that join vertices between each Community to itself from the expected fraction in a random network.
      Returns:
      the modularity
    • mergeCommunities

      public void mergeCommunities(int j, int i)
      Merge community j and i into j
      Parameters:
      j - the community to store the result
      i - the community the offers its Nodes
    • toString

      public String toString()
      Overrides:
      toString in class Object